// require('babel-polyfill')
import $, { get } from 'jquery';
import { render } from 'less';
import {api} from '../api.js'
// require('../css/base.css');
require('../css/com.css');
require('../css/style_zn.css')


$(function(){
    $(".import").click(function () {
        $(".username_zn").css("border-bottom-color", "#0092EF");
        $(".psd_zn").css("border-bottom-color", "#c2c3c2");
    });

    $(".password").click(function () {
        $(".psd_zn").css("border-bottom-color", "#0092EF");
        $(".username_zn").css("border-bottom-color", "#c2c3c2");
    })

    var $loginBtn = $('.js_login_chq');
    var $userName = $('.js_userName_chq');
    var $password = $('.js_password_chq')


    // 点击登录按钮
    $loginBtn.on('click',function(e) {
        e.stopPropagation();
        
        var userNameText = $userName.val();
        var passwordText = $password.val();
        if(userNameText === '') {
            alert('用户名不能为空');
            return;
        }
        if(passwordText === '') {
            alert('密码不能为空');
            return;
        }

        lgoinIn(userNameText,passwordText)
    })

// 登录请求
function lgoinIn(userNameText,passwordText) {
    $.post(api.login, {
        "loginName":userNameText,
        "password":passwordText
    },function(data){
        if(data.code === 200) {
            self.location.href="index.html"
            $userName.val('');
            $password.val('');
        }else {
            alert(data.message);
        }
        
    });

}


});